﻿using OMG.Fill.Mulberry.Model.Ent;
using OMG.Fill.Mulberry.Service;
using ProjectShare;
using System.Collections.Generic;
using System.Web.Http;
namespace OMG.Fill.Mulberry.Model.UI.Controllers
{
    public class AreaController : ApiController
    {
        AreaServices areaServices = new AreaServices();
        
        //[ApiActionAuthorize("获取行政区划表T_Area分页列表对象操作")]
        //[ApiActionException]
        public Pager<List<AreaEntity>> PostPageList(AreaQuery query)
        {
            return areaServices.GetPageList(query);
        }
        //[ApiActionAuthorize("新增行政区划表T_Area指定对象操作")]
        //[ApiActionException]
        public ResResult<int> Post(AreaEntity model) {
            return areaServices.AddInfo(model);
        }
        //[ApiActionAuthorize("修改行政区划表T_Area指定对象操作")]
        //[ApiActionException]
        public ResResult<int> Put(AreaEntity model)
        {
            return areaServices.UpdateInfo(model);
        }
        //[ApiActionAuthorize("删除行政区划表T_Area指定对象操作")]
        //[ApiActionException]
        public ResResult<int> Delete(string id)
        {
            return areaServices.DeleteInfo(id);
        }
        //[ApiActionAuthorize("获取行政区划表T_Area指定对象操作")]
        //[ApiActionException]
        public ResResult<AreaEntity> Get(string id)
        {
            return areaServices.GetModel(id);
        }

        /// <summary>
        /// 获取全部列表
        /// </summary>
        /// <returns></returns>
        public ResResult<List<AreaEntity>> Get()
        {
            return areaServices.GetList();
        }
        /// <summary>
        /// 获取级联选择框数据
        /// </summary>
        /// <param name="Code"></param>
        /// <returns></returns>
        public ResResult<List<CascaderTreeModel>> GetCascaderTree(string id)
        {
            id = id == null ? "" : id;
            return areaServices.GetCascaderTreeList(id);
        }
        public ResResult<List<AreaTreeModel>> GetAreaTree(string id)
        {
            id = id == null ? "" : id;
            return areaServices.GetAreaModelTreeList(id);
        }
        public ResResult<List<CascaderModel>> GetCascaderList(string id)
        {
            id = id == null ? "" : id;
            return areaServices.GetCascaderList(id);
        }
    }
}